#ifndef BANK_HPP
#define BANK_HPP

#include <QObject>
#include <QMap>
#include <QMapIterator>

#include "register.hpp"
#include "ioregister.hpp"

/**
* @brief Class representing a memory Bank of the PIC
* @details This class contains all Registers which are included in the Bank.
* The registers are stored in a Map to provide fast access via their address.
* @see Register
*
* @class Bank bank.hpp "bank.hpp"
*/
class Bank : public QObject
{
Q_OBJECT
public:
    /**
    * @brief Creates a new instance
    *
    * @fn explicit Bank(QObject *parent = 0)
    * @param parent
    */
    explicit Bank(QObject *parent = 0);

    /**
    * @brief Copy Constructor for Bank
    * @details Copies all contents of one Bank into a new Object \n
    * You need to delete the copied Object yourself!
    *
    * @fn Bank(const Bank &other)
    * @param other
    */
    Bank(const Bank &other);

    /**
    * @brief Bank's Destructor
    *
    * @fn ~Bank
    */
    ~Bank();

    /**
    * @brief Returns a Register
    * @details Returns a Pointer to an Register in the internal data storage \n
    * With this function you can get the Registers of this Bank. \n
    * Access to another Bank is \b NOT \b possible
    *
    * @fn Register *getRegister(int address)
    * @param address
    * @return Register
    */
    Register *getRegister(int address);

    /**
    * @brief Adds a new Register for the given address
    * @details This function will add a specified Register with the given address to the Bank. \n
    * There is no logic which will check for double entries, so make sure to delete Registers before you re-add one
    *
    * @fn void addRegister(int address, Register *reg)
    * @param address
    * @param reg
    */
    void addRegister(int address, Register *reg);

    /**
    * @brief Get the current Register Map
    * @details Will return a const reference to the internal data storage \n
    * Only the Registers of this Bank will be returned
    *
    * @fn const QMap<int, Register*> &getRegisterMap() const
    * @return const QMap<int, Register *>
    */
    const QMap<int, Register*> &getRegisterMap() const;

    /**
    * @brief Reset the Bank
    * @details Reset the Bank to the default settings \n
    * This will perform a complete reset of all internal Registers
    *
    * @fn reset
    */
    void reset();

private:
    QMap<int, Register*> registerMap;

};

#endif // BANK_HPP
